package com.hankol.community.adapter

import android.app.Activity
import android.widget.LinearLayout
import android.widget.RelativeLayout
import com.baselibrary.manager.SensorsDataManager
import com.baselibrary.utils.ARouterUtils
import com.baselibrary.utils.DoubleClickHelper
import com.baselibrary.utils.GlideUtils
import com.baselibrary.utils.ScreenUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hankol.community.R
import com.hankol.community.bean.DiscoverListItemBean
import com.hankol.community.bean.MajorPlateRule
import com.hankol.community.bean.QuickLink

/**
 * @author: yuyang、
 * @date: 2023/04/17
 * @Des：首页金刚区
 */
class DiscoverLockAdapter : BaseQuickAdapter<QuickLink, BaseViewHolder>(R.layout.item_discover_lock) {
    lateinit var activity: Activity
    fun setShowRule(activity: Activity) {
        this.activity = activity
    }

    override fun convert(helper: BaseViewHolder, item: QuickLink) {
        helper.let {
            val root = it.getView<LinearLayout>(R.id.ll_root)
            val p = root.layoutParams
            p.width = ((ScreenUtils.getScreenWidth() - ScreenUtils.dpToPx(28)).toFloat() / 5).toInt()
            root.layoutParams = p
            it.setText(R.id.tv_lock_title, item.name)
            GlideUtils.loadImg_228(mContext, item.img, it.getView(R.id.iv_cover))
            it.itemView.setOnClickListener {
                if (!DoubleClickHelper.isOnDoubleClick()) {
                    SensorsDataManager.instance.homeJingangClick(item.name)
                    ARouterUtils.bannerJump(activity, item.routeType, item.routeUrl, item.appletId)
                }
            }
        }
    }

}